package com.dreamsinpost;

import com.dreamsinpost.activity.Main;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.MotionEvent;

public class DreamsInPostActivity extends Activity{

	public static final int FORM_MAIN = 1000;
	public static final int FORM_SETTINGS = 1001;
	public static final int FORM_CAMERA = 1002;
	public static final int ACTIVITI_SELECT_MEDIA_FILE = 1002;
	
	
	protected boolean _active = true;
	protected int _splashTime = 2000; // time to display the splash screen in ms
	
	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.splash);
        
        viewSplash();
        
    }
	
    private void viewSplash() {
    	
		Thread splashTread = new Thread() {
	        @Override
	        public void run() {
	            try {
	                int waited = 0;
	                while(_active && (waited < _splashTime)) {
	                    sleep(100);
	                    if(_active) {
	                        waited += 100;
	                    }
	                }
	                
	            } catch(InterruptedException e) {
	            	
	            } finally {
	                finish();
	                startActivityForResult(new Intent (getApplicationContext(), Main.class), FORM_MAIN);
	                interrupt();
	            }
	        }
	    };
	    splashTread.start();  
    	
    }
    
	@Override
	public boolean onTouchEvent(MotionEvent event) {
	    if (event.getAction() == MotionEvent.ACTION_DOWN) {
	        _active = false;
	    }
	    return true;
	}
	


	
}